package com.zjw.hyphenateui;

import android.app.Application;
import android.content.Context;
public class MainApplication extends Application {

    private static MainApplication instance;
    private static MyActivityLifecycle myActivityLifecycle;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        myActivityLifecycle = new MyActivityLifecycle();
        registerActivityLifecycleCallbacks(myActivityLifecycle);

    }

    /**
     *
     * @return  true  处于后台   false  前台
     */
    public static boolean isAppBackground() {
        if (myActivityLifecycle.getStartCount() == 0) {
            return true;
        }
        return false;
    }


    public static Context getAppContext() {
        return instance.getApplicationContext();
    }
}
